package main

import "fmt"

func main() {
	//结构体的实例化
	var person Person
	person.name = "chen"
	person.age = 23
	person.city = "重庆"

	//fmt.Printf("%#v\n", person)
	//
	//var p1 = new(Person)
	//fmt.Printf("%T", p1)
	//
	////结构体定义
	//p2 := Person{
	//	name: "",
	//	age:  111,
	//	city: "",
	//}
	//fmt.Println(p2)
	//
	////值列表
	//p3 := Person{
	//	"",
	//	"",
	//	11,
	//}
	//fmt.Println(p3)

	p4 := newP("hello", 22, "重庆")
	//person.Dream()
	p4.Dream()

}

//结构体 内存对齐 相同类型字段放在一起更加节省内存
type Person struct {
	name, city string
	age        int8
}

func newP(name string, age int8, city string) *Person {

	return &Person{
		name: name,
		age:  age,
		city: city,
	}
}

func (p Person) Dream() {
	fmt.Printf("%s的梦想是学好go\n", p.name)
}
